#include "stdafx.h"

#include "SpotLight.h"

namespace PM3D
{
    SpotLight::SpotLight(const D3DXCOLOR& ambient, const D3DXCOLOR& diffuse, 
            const D3DXCOLOR& specular, const D3DXVECTOR3& position, 
            const D3DXVECTOR3& direction, const D3DXVECTOR3& attenuation, 
            const float range, const float fallOff, const float theta, 
            const float phi) 
            : Light(ambient,diffuse,specular)
    {
        light_.Type = D3DLIGHT_SPOT;
        light_.Direction = direction;
        light_.Position = position;
        light_.Attenuation0 = attenuation.x;
        light_.Attenuation1 = attenuation.y;
        light_.Attenuation2 = attenuation.z;
        light_.Range  = range;
        light_.Falloff = fallOff;
        light_.Theta = theta;
        light_.Phi = phi;
    }

    SpotLight::~SpotLight()
    {
    }

    ///////////////////////////////////////////////////
    // Getter
    ///////////////////////////////////////////////////
    D3DXVECTOR3 SpotLight::getAttenuation() const
    {
        return D3DXVECTOR3(light_.Attenuation0, light_.Attenuation1, light_.Attenuation2);
    }

    D3DXVECTOR3 SpotLight::getPosition() const
    {
        return light_.Position;
    }

    D3DXVECTOR3 SpotLight::getDirection() const
    {
        return light_.Direction;
    }

    float SpotLight::getRange() const
    {
        return light_.Range;
    }

    float SpotLight::getFallOff() const
    {
        return light_.Falloff;
    }

    float SpotLight::getTheta() const
    {
        return light_.Theta;
    }

    float SpotLight::getPhi() const
    {
        return light_.Phi;
    }

    ///////////////////////////////////////////////////
    // Setter
    ///////////////////////////////////////////////////
    void SpotLight::setPosition(const D3DXVECTOR3& position)
    {
        light_.Position = position;
    }

    void SpotLight::setDirection(const D3DXVECTOR3& direction)
    {
        light_.Direction = direction;
    }

    void SpotLight::setAttenuation(const D3DXVECTOR3& attenuation)
    {
        light_.Attenuation0 = attenuation.x;
        light_.Attenuation1 = attenuation.y;
        light_.Attenuation2 = attenuation.z;
    }

    void SpotLight::setRange(const float range)
    {
        light_.Range = range;
    }

    void SpotLight::setFalloff(const float fallOff)
    {
        light_.Falloff = fallOff;
    }

    void SpotLight::setTheta(const float theta)
    {
        light_.Theta = theta;
    }

    void SpotLight::setPhi(const float phi)
    {
        light_.Phi = phi;
    }

}   //namespace PM3D
